package business.impl;

import java.sql.ResultSet;
import java.util.List;

import model.TPractice;
import model.TUser;
import business.basic.iHibBaseDAO;
import business.basic.iHibBaseDAOImpl;
import business.dao.UserDao;

public class UserDaoImpl implements UserDao {
	
	iHibBaseDAO bdao = null;
	public void setBdao (iHibBaseDAO bdao){
		this.bdao=bdao;
		
	}

	@Override
	public TUser getUserById(int id) {
		TUser title = (TUser) bdao.findById(TUser.class,id);
		return title;
	}

	@Override
	public int adduser(TUser model) {
		String obj = (String) bdao.insert(model);
		if (obj == null) {
			return 0;
		}
		return 1;
		
	}

	@Override
	public boolean upuser(TUser model) {
		return bdao.update(model);
	}

	

	@Override
	public TUser login(String userid, String pwd) {
		String sql = " from TUser where account = ? and pwd = ? ";
		Object[] para = {userid,pwd};
		TUser modl =  (TUser) bdao.selectby(sql,para);
		return modl;
	}

}
